//
//  MyAdvisoryProcessingOrderCell.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/3/31.
//  Copyright © 2020 tao Tao. All rights reserved.
//

import UIKit

class MyAdvisoryCommentOrderCell: UITableViewCell {
    
    @IBOutlet weak var businessTypeLabel: UILabel!{
        didSet{
            businessTypeLabel.layer.cornerRadius = 5
            businessTypeLabel.layer.masksToBounds = true
        }
    }
    func configure(with vm: MyAdvisoryOrderRowViewModel) {
        avatarView.kf.setImage(with: URL(string: vm.url),
                               placeholder: UIImage(named: "avatar_default"))
        nameLabel.text = vm.doctorName
        departmentLabel.text = vm.departmentName
        statusLabel.text = vm.status.description()
        statusLabel.textColor = vm.status.statusColor()
        patientLabel.text = "就诊人：\(vm.patientName)"
        diagnoseLabel.text = "主诊断：\(vm.diagnoseName)"
        endTimeLabel.text = "结束时间：\(vm.endTime)"
        
        ///业务类型-1:咨询2:复诊
        if vm.model.businessType == 1 {
            businessTypeLabel.text = "咨询"
        }else if vm.model.businessType == 2{
            businessTypeLabel.text = "复诊"
        }
    }
    
    @IBOutlet private weak var containerView: UIView! {
        didSet {
            containerView.layer.cornerRadius = 8
            containerView.layer.masksToBounds = true
        }
    }
    
    @IBOutlet private weak var avatarView: UIImageView! {
        didSet {
            avatarView.contentMode = .scaleAspectFill
            avatarView.layer.cornerRadius = avatarView.height * 0.5
            avatarView.layer.masksToBounds = true
        }
    }
    
    @IBOutlet private weak var nameLabel: UILabel!
    
    @IBOutlet private weak var departmentLabel: UILabel! {
        didSet {
            departmentLabel.textColor = .mainColor
            departmentLabel.font = .regular_14
        }
    }
    
    @IBOutlet private weak var statusLabel: UILabel! {
        didSet {
            statusLabel.textColor = .mainColor
            statusLabel.font = .regular_14
        }
    }
    
    @IBOutlet private weak var endTimeLabel: UILabel! {
        didSet {
            endTimeLabel.textColor = .textLight
            endTimeLabel.font = .regular_14
        }
    }
    
    @IBOutlet private weak var diagnoseLabel: UILabel! {
        didSet {
            diagnoseLabel.textColor = .textLight
            diagnoseLabel.font = .regular_14
        }
    }
    
    @IBOutlet private weak var patientLabel: UILabel! {
        didSet {
            patientLabel.textColor = .textLight
            patientLabel.font = .regular_14
        }
    }
    
    @IBOutlet private weak var commentBtn: UIButton! {
        didSet {
            commentBtn.isUserInteractionEnabled = false
            commentBtn.setTitle("待评价", for: .normal)
            commentBtn.titleLabel?.font = .regular_14
            commentBtn.setTitleColor(.white, for: .normal)
            commentBtn.setTitleColor(.main, for: .highlighted)
            commentBtn.setBackgroundImage(UIImage(color: .mainColor), for: .normal)
            commentBtn.setBackgroundImage(UIImage(color: .mainLight), for: .highlighted)
            commentBtn.layer.cornerRadius = commentBtn.height / 2
            commentBtn.layer.masksToBounds = true
        }
    }
}
